<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="/layout/template.xhtml">

<ui:define name="body">

    <h:form id="administradorGrupo" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{administradorGrupoHome.managed ? 'Editar' : 'Cadastro de'} Administrador de Grupo</f:facet>

			<s:div styleClass="tableControl" rendered="#{s:hasRole('AdministradorGeral') and empty from}">
        		<s:link view="/resources/AdministradorGrupoList.xhtml"
		                    id="list"
		           propagation="none">
		            <h:graphicImage url="/img/list.png"/>
		            #{' '}
		            <h:outputLabel value="Listagem"/>
		        </s:link>
		    </s:div>
			
			<s:decorate id="nomeField" template="/layout/edit.xhtml">
                <ui:define name="label">Nome</ui:define>
                <h:inputText id="nome" value="#{administradorGrupoHome.instance.nome}" required="true"/>
            </s:decorate>


			<s:decorate id="emailField" template="/layout/edit.xhtml">
                <ui:define name="label">E-mail</ui:define>
                <h:inputText id="email" value="#{administradorGrupoHome.instance.email}" required="true">
                	<a:support event="onblur" reRender="emailField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>
            
            
            <s:decorate id="statusField" template="/layout/edit.xhtml">
				<ui:define name="label">Status</ui:define>
            	<h:selectOneRadio id="status" value="#{administradorGrupoHome.instance.status}" styleClass="radio" required="true">
                    <f:selectItem itemLabel="Ativo" itemValue="Ativo"/>
                    <f:selectItem itemLabel="Inativo" itemValue="Inativo"/>
                </h:selectOneRadio>
			</s:decorate>


			<s:decorate id="logradouroField" template="/layout/edit.xhtml">
                <ui:define name="label">Logradouro</ui:define>
                <h:inputText id="logradouro" value="#{administradorGrupoHome.instance.logradouro}" required="true"/>
            </s:decorate>
            

            <s:decorate id="numeroField" template="/layout/edit.xhtml">
                <ui:define name="label">Numero</ui:define>
                <h:inputText id="numero" value="#{administradorGrupoHome.instance.numero}" size="10" maxlength="10" required="true"/>
            </s:decorate>
            

            <s:decorate id="bairroField" template="/layout/edit.xhtml">
                <ui:define name="label">Bairro</ui:define>
                <h:inputText id="bairro" value="#{administradorGrupoHome.instance.bairro}" required="true"/>
            </s:decorate>


			<s:decorate id="complementoField" template="/layout/edit.xhtml">
                <ui:define name="label">Complemento</ui:define>
                <h:inputText id="complemento" value="#{administradorGrupoHome.instance.complemento}" />
            </s:decorate>
            

            <s:decorate id="UFField" template="/layout/edit.xhtml">
                <ui:define name="label">Estado</ui:define>
                <h:inputText id="UF" value="#{administradorGrupoHome.instance.UF}" size="4" maxlength="4" required="true"/>
            </s:decorate>


            <s:decorate id="cidadeField" template="/layout/edit.xhtml">
                <ui:define name="label">Cidade</ui:define>
                <h:inputText id="cidade" value="#{administradorGrupoHome.instance.cidade}" required="true"/>
            </s:decorate>

            
            <s:decorate id="CEPField" template="/layout/edit.xhtml">
                <ui:define name="label">CEP</ui:define>
                <h:inputText id="CEP" value="#{administradorGrupoHome.instance.CEP}" maxlength="8" required="true"/>
            </s:decorate>

            
            <s:decorate id="senhaField" template="/layout/edit.xhtml">
				<ui:define name="label">Senha</ui:define>
            	<h:inputSecret value="#{administradorGrupoHome.instance.senha}" required="true"/>
			</s:decorate>

			<s:decorate id="confirmarSenhaField" template="/layout/edit.xhtml">
				<ui:define name="label">Confirmar Senha</ui:define>
            	<h:inputSecret value="#{administradorGrupoHome.instance.confirmarSenha}" required="true"/>
			</s:decorate>


            <div style="clear:both">
                <span class="required">*</span>
                campos obrigatórios
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Salvar"
                         action="#{administradorGrupoHome.persist}"
                       disabled="#{!administradorGrupoHome.wired}"
                       rendered="#{!administradorGrupoHome.managed}"/>

            <h:commandButton id="update"
                          value="Salvar"
                         action="#{administradorGrupoHome.update}"
                       rendered="#{administradorGrupoHome.managed}"/>

            <h:commandButton id="delete"
                          value="Deletar"
                         action="#{administradorGrupoHome.remove}"
                      immediate="true"
                       rendered="#{administradorGrupoHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancelar"
             propagation="end"
                    view="/resources/AdministradorGrupo.xhtml"
                rendered="#{administradorGrupoHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancelar"
             propagation="end"
                    view="/resources/#{empty administradorGrupoFrom ? 'AdministradorGrupoList' : administradorGrupoFrom}.xhtml"
                rendered="#{!administradorGrupoHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Telefone">
        <h:form styleClass="association" id="telefoneChildren">

            <h:outputText value="Não existe(m) telefone(s) associado(s)."
                       rendered="#{empty administradorGrupoHome.telefone}"/>

            <rich:dataTable value="#{administradorGrupoHome.telefone}"
                           var="_telefone"
                      rendered="#{not empty administradorGrupoHome.telefone}"
                    rowClasses="odd, even"
                            id="telefoneTable"
                          rows="15">
                <rich:column sortBy="#{_telefone.contato}">
                    <f:facet name="header">Contato</f:facet>
                    <h:outputText value="#{_telefone.contato}"/>
                </rich:column>
                <rich:column sortBy="#{_telefone.numero}">
                    <f:facet name="header">Número</f:facet>
                    <h:outputText value="#{_telefone.numero}"/>
                </rich:column>
                <rich:column sortBy="#{_telefone.ramal}">
                    <f:facet name="header">Ramal</f:facet>
                    <h:outputText value="#{_telefone.ramal}"/>
                </rich:column>
                <rich:column sortBy="#{_telefone.tipoTelefone}">
                    <f:facet name="header">Tipo do Telefone</f:facet>
                    <h:outputText value="#{_telefone.tipoTelefone}"/>
                </rich:column>
            </rich:dataTable>
            
            <br clear="left"/>
            
			<rich:datascroller renderIfSinglePage="false" for="telefoneTable"/>
        </h:form>

        <f:subview rendered="#{administradorGrupoHome.managed}" id="telefone">
        <div class="actionButtons">
            <s:button id="addtelefone"
                   value="Novo Telefone"
                    view="/resources/TelefoneEdit.xhtml"
             propagation="none">
                 <f:param name="administradorGrupoId"
                         value="#{administradorGrupoHome.instance.id}"/>
                 <f:param name="telefoneFrom" value="AdministradorGrupo"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>
    
    <rich:tab label="Grupo">
    	<h:form styleClass="association" id="grupoChildren">
    		<h:outputText value="Não existe(m) grupo(s) associado(s)."
                       rendered="#{empty administradorGrupoHome.grupo}"/>
            
            <rich:dataTable value="#{administradorGrupoHome.grupo}"
                           var="_grupo"
                      rendered="#{not empty administradorGrupoHome.grupo}"
                    rowClasses="odd, even"
                            id="grupoTable"
                          rows="15">
                          
                <rich:column sortBy="#{_grupo.nome}">
                    <f:facet name="header">Nome</f:facet>
                    <h:outputText value="#{_grupo.nome}"/>
                </rich:column>
                <rich:column sortBy="#{_grupo.descricao}">
                    <f:facet name="header">Descrição</f:facet>
                    <h:outputText value="#{_grupo.descricao}"/>
                </rich:column>
                <rich:column sortBy="#{_grupo.email}">
                    <f:facet name="header">E-mail</f:facet>
                    <h:outputText value="#{_grupo.email}"/>
                </rich:column>
                <rich:column sortBy="#{_grupo.dataCadastro.time}">
                    <f:facet name="header">Data de Cadastro</f:facet>
                    <h:outputText value="#{_grupo.dataCadastro.time}"/>
                </rich:column>
                <rich:column sortBy="#{_grupo.status}">
                    <f:facet name="header">Status</f:facet>
                    <h:outputText value="#{_grupo.status}"/>
                </rich:column>
            </rich:dataTable>
            
            <br clear="left"/>
            
            <rich:datascroller renderIfSinglePage="false" for="grupoTable"/>
    	</h:form>
    	
    	<f:subview rendered="#{administradorGrupoHome.managed}" id="grupo">
        <div class="actionButtons">
            <s:button id="addgrupo"
                   value="Novo Grupo"
                    view="/resources/GrupoEdit.xhtml"
             propagation="none">
                 <f:param name="administradorGrupoId"
                         value="#{administradorGrupoHome.instance.id}"/>
                 <f:param name="grupoFrom" value="AdministradorGrupo"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
